/**
 * 
 */
package org.istt.service.impl;

import java.util.List;

import org.istt.dao.ExchangeDao;
import org.istt.domain.Exchange;
import org.istt.service.ExchangeManager;
import org.istt.web.helper.ExtendedPaginatedList;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("exchangeManager")
public class ExchangeManagerImpl extends ManagerImpl<Exchange, Long> implements ExchangeManager {
	/**
	 * @param categoryDao the categoryDao to set
	 */
	@Autowired
	public void setExchangeDao(ExchangeDao dao) {
		this.dao = dao;
	}

	@Override
	public ExtendedPaginatedList getLstExchangeMessageByReceiver(Long receiverId,ExtendedPaginatedList paginatedList) {
		// TODO Auto-generated method stub
		List<Exchange> results = ((ExchangeDao)dao).getExchangeMessageByReceiver(receiverId, paginatedList
                .getFirstRecordIndex(), paginatedList.getPageSize(), paginatedList
                .getSortDirection(), paginatedList.getSortCriterion());
			
        paginatedList.setList(results);
        paginatedList.setTotalNumberOfRows(((ExchangeDao)dao).getRecordCountByReceiver(receiverId));
		return paginatedList;
	}

	@Override
	public Boolean checkNewMessage(Long receiverId, boolean status) {
		// TODO Auto-generated method stub
		int results = ((ExchangeDao)dao).getNumberOfMessageByReceiver(receiverId, status);
		if(results!=0) return true;
		
		return false;
	}

	@Override
	public List<Exchange> getExchangeMessageByFile(String fileId, DateTime date) {
		// TODO Auto-generated method stub
		return ((ExchangeDao)dao).getExchangeMessageByFile(fileId, date);
	}

}
